import React from 'react';
import { baseRouter } from '@/router/interface';
import { lazyLoad } from '@/router/util/lazyLoad';
import HomeLayout from '@/layout/homeLayout';

const isHidden = !['0', '1'].includes(sessionStorage.getItem('roleType') ?? '-1')

const asyncRoutes: baseRouter[] = [
  {
    // 首页
    path: '/home',
    element: <HomeLayout />,
    children: [
      {
        path: '/home/index',
        element: lazyLoad(() => import('@/views/home')),
        meta: {
          title: 'index',
          icon: 'BankOutlined'
        }
      }
    ]
  },
  {
    // 用户管理
    path: '/userManagement',
    element: <HomeLayout />,
    meta: {
      title: 'userManagement',
      icon: 'SettingOutlined'
    },
    children: [
      {
        path: '/userManagement/user',
        element: lazyLoad(() => import('@/views/userManagement/user')),
        meta: {
          title: 'userList',
          icon: 'UsergroupDeleteOutlined'
        }
      }
    ]
  },
  {
    // 题库管理
    path: '/questionsBank',
    element: <HomeLayout />,
    meta: {
      title: 'questionsBank',
      icon: 'SettingOutlined'
    },
    children: [
      {
        path: '/questionsBank/questions',
        element: lazyLoad(() => import('@/views/questionBank/questions')),
        meta: {
          title: 'questions',
          icon: 'UserOutlined'
        }
      },
      {
        path: '/questionsBank/tags',
        element: lazyLoad(() => import('@/views/questionBank/tags')),
        meta: {
          title: 'tags',
          icon: 'UserOutlined'
        }
      }
    ]
  },
  {
    // 笔试管理
    path: '/written',
    element: <HomeLayout />,
    meta: {
      title: 'writtenManagement',
      icon: 'BlockOutlined'
    },
    children: [
      {
        // 试卷管理
        path: '/written/paper',
        element: lazyLoad(() => import('@/views/written/paper')),
        meta: {
          title: 'paper',
          icon: 'ProjectOutlined'
        }
      },
      {
        // 分类管理
        path: '/written/categories',
        element: lazyLoad(() => import('@/views/written/categories')),
        meta: {
          title: 'categories',
          icon: 'ProjectOutlined'
        }
      },
      {
        // 考试管理
        path: '/written/exam',
        element: lazyLoad(() => import('@/views/written/exam')),
        meta: {
          title: 'exam',
          icon: 'ProjectOutlined'
        }
      }
    ]
  },
  {
    // 考试详情管理
    path: '/examDetails',
    element: <HomeLayout />,
    meta: {
      title: 'examDetails',
      icon: 'BlockOutlined'
    },
    children: [
      {
        path: '/examDetails/answers',
        element: lazyLoad(() => import('@/views/examDetails/answers')),
        meta: {
          title: 'examAnswers',
          icon: 'ProjectOutlined'
        }
      },
      {
        // 考试内容
        path: '/examDetails/results',
        element: lazyLoad(() => import('@/views/examDetails/results')),
        meta: {
          title: 'examResults',
          icon: 'ProjectOutlined'
        }
      }
    ]
  },
  {
    // 帖子管理
    path: '/forumManagement',
    element: <HomeLayout />,
    meta: {
      title: 'forumManagement',
      icon: 'BlockOutlined'
    },
    children: [
      {
        path: '/forumManagement/addForums',
        element: lazyLoad(() => import('@/views/forumManagement/content/addForums')),
        meta: {
          title: 'addForums',
          icon: 'ProjectOutlined'
        }
      },
      {
        path: '/forumManagement/posts',
        element: lazyLoad(() => import('@/views/forumManagement/content')),
        meta: {
          title: 'forumContent',
          icon: 'ProjectOutlined'
        }
      },
      {
        path: '/forumManagement/comment',
        element: lazyLoad(() => import('@/views/forumManagement/comment')),
        meta: {
          title: 'forumComment',
          icon: 'ProjectOutlined'
        }
      }
    ]
  },
  {
    // 文章管理
    path: '/posts',
    element: <HomeLayout />,
    meta: {
      title: 'posts',
      icon: 'BlockOutlined'
    },
    children: [
      {
        path: '/posts/add',
        element: lazyLoad(() => import('@/views/postsManagement/addPosts')),
        meta: {
          title: 'addPosts',
          icon: 'ProjectOutlined'
        }
      },
      {
        path: '/posts/content',
        element: lazyLoad(() => import('@/views/postsManagement')),
        meta: {
          title: 'postsManagement',
          icon: 'ProjectOutlined'
        }
      }
    ]
  }
];

export default asyncRoutes;
